<form class="form-horizontal form-modal" method="post" enctype="multipart/form-data" id="editForm">
    <input type="number" class="form-control" name="num" value="{$num}" hidden id="num">
    <input type="number" class="form-control" name="project_id" value="{$info->project_id}" hidden>
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">编辑题目</h4>
            </div>
            <div class="modal-body">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">标题 ：</label>
                            <div class="col-sm-10">
                                <textarea class="form-control" rows="2" name="title">{$info->title}</textarea>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">题目 ：</label>
                            <div class="col-sm-10">
                                <textarea class="form-control" rows="2" name="subject">{$info->subject}</textarea>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">分数 ：</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="num" value="{$info->num}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group row">
                            <label class="col-sm-2 control-label">类型 ：</label>
                            <div class="col-sm-10">
                                <select class="chosen-select" name="type">
                                    <option value="0" {if $info->type == 0}selected {/if}>单选</option>
                                    <option value="1" {if $info->type == 1}selected {/if}>多选</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">排序 ：</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="sort" value="{$info->sort}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">考核答案 ：</label>
                            <div class="col-sm-10" id="div1" style="float: left">
                                <img src="{__ADMIN__}/img/jiahao.png" height="50" onclick="content()">
                                {foreach $info->content as $key => $item}
                                    <div id="num{$key}" style="display: flex;">
                                        <input type="text" class="form-control" name="content[{$item->id}]" value="{$item->content}">
                                        <img src="{__ADMIN__}/img/dacha.jpg" height="35px" onclick="content_delete('num{$key}')">
                                    </div>
                                {/foreach}
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>


                        <div class="form-group row">
                            <label class="col-sm-2 control-label">正确答案 ：</label>
                            <div class="col-sm-10">
                                <input type="text" class="tagsinput form-control" name="real" value="{$info->content_ids}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">状态 ：</label>
                            <div class="col-sm-10">
                                <label class="lab-radio">
                                    <input type="radio" value="1" name="status" {if $info->status == 1}checked {/if}>显示
                                </label>
                                <label class="lab-radio">
                                    <input type="radio" value="0" name="status" {if $info->status == 0}checked {/if}>隐藏
                                </label>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="post_form($(this),'{$Think.config.admin.app_host}/admin/project/topic/{$info->id}')">保存
                </button>
            </div>
        </div>
    </div>
</form>

<script>
    $(function () {
        $('.chosen-select').chosen({width: "100%"});
    })

    function content() {
        var num = $('#num').val();
        $('#num').val(num*1+1);
        var data = ' <div id = "num'+ num +'"><input type="text" class="form-control" name="content[]">'+' <img src="{__ADMIN__}/img/dacha.jpg" height="35px"  onclick="content_delete(&#39num'+ num +'&#39)" > </div>';
        $('#div1').append(data);
    }

    function content_delete(num) {
        $('#'+num+'').remove();
    }
</script>
